<style>
    .list-ctx .head .tag {
        line-height:initial;
    }
</style>

<template>
    <div>
        <div class="loader-base" v-if="showLoad"><div class="loader-wrap"></div></div>
        <div class="displayflex top-bar-w" style="margin-bottom:10px; border-bottom:1px solid #e5e5e5">
            <div class="top-bar-c flex1">
                <i class="iconfont icon-sech"></i> 
                <div class="ipt"><input type="text" placeholder="输入订单号" v-model="bbillno"></div>
            </div> 
            <div class="btn-sech" @click="resetGet()">搜索</div>
        </div>
        <scroller lock-x height="-52" @on-scroll-bottom="onScrollBottom" ref="scrollerBottom" :scroll-bottom-offst="0" v-show="todolist.length>0">
            <div>
                <div class="list-warp" v-for="item in todolist">
                    <div class="list-ctx" @click="goDetail(item.BBillGuid)">
                        <div class="head cf ft14">
                            <p class="lft f-l">{{item.BBillNo}}</p>
                            <span class="tag claim f-l">{{item.ClaimState | claimState}}</span>
                        </div>
                        <div class="grab-wrap">
                        <!--
                            <div class="addr ft15"><span class="dotted"></span>{{item.DepartureProvince | province}}{{item.DepartureCity | city}}{{item.DepartureDistrict | district}}{{item.DepartureAddress}}</div>
                            <div class="addr ft15"><span class="dotted org"></span>{{item.ArrivalProvince | province}}{{item.ArrivalCity | city}}{{item.ArrivalDistrict | district}}{{item.ArrivalAddress}}</div>
                        -->
                            <div class="statis ft14 displayflex">
                                <span>{{item.OrdersWeight | weight}}，{{item.OrdersVolumn | volumn}}，共{{item.OrdersPKGS}}件</span>
                                <div class="flex1 txt-rit">保费：<span class="price org" v-if="item.InsuranceFee >0"><em>￥</em>{{item.InsuranceFee}}</span><span class="price org" v-else>平台赠送</span></div>
                            </div>
                            
                            <!--<div class="ft14">异常原因：<span class="org">{{item.ExcpetionReason}}</span></div>-->
                            <div class="ft14">投保公司：<span class="gray">{{item.InsuranceCompany}}</span></div>
                            <div class="ft14">保险单号：<span class="gray">{{item.InsuranceNo}}</span></div>
                            <div class="ft14">保价金额：<span class="org"><em>￥</em>{{item.InsuranceAmount | fixed00}}</span></div>
                            <div class="ft14">定损金额：<span class="org" v-if="item.ClaimAmount > 0"><em>￥</em>{{item.ClaimAmount | fixed00}}</span><span class="gray" v-else>还未定损</span></div>
                            <div class="ft14">理赔原因：<span class="gray" style="word-break:break-all">{{item.ClaimMemo}}</span></div>
                        </div>
                    </div>
                </div>
            </div>
            <p class="txt-bottom" v-if="totalLength == todolist.length && totalLength>3"><em class="txt">我是有底线的</em></p>
        </scroller>
        <div class="noDate_page" v-if="todolist.length<=0">
            <div class="noDate_icon"><i class="iconfont icon-null"></i></div>
            未找到相关数据
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return{
            showLoad:false,

            todolist:[],
            totalLength: 0,
            bbillno: '',
            count: 0,
            pageindex: 1,
        }
    },
    computed:{
        userinfo(){
            if(localStorage.UserInfo){
            return JSON.parse(localStorage.UserInfo)
            };
        },
    },
    watch:{
        bbillno(val){
            if(!val){
            this.resetGet();
            }
        }
    },
    created() {
        this.getData();
    },
    methods:{
        getData(){
            var self = this;
            if (this.totalLength == this.todolist.length && this.todolist.length > 0) {
                return false;
            }
            var query = { 
                CorpGuid: this.userinfo.CorpGuid,
                BBillNo: this.bbillno,
                PageIndex:this.pageindex,
                InsuraceState: 2,
                State: '82',
                PageSize:8
            };
            this.showLoad = true;
            this.Ajax.post("SearchOrderList", query).then(function(resp) {
                self.showLoad = false;
                if (resp.IsSuccess) {
                    var result = resp.Datas;
                    if(result.length > 0){
                        self.todolist = self.todolist.concat(result);
                        self.pageindex++;
                        self.count = 0;
                    };
                    self.totalLength = resp.TotalRecords;
                    if (self.pageindex == 2) {
                        self.$nextTick(() => {
                            self.$refs.scrollerBottom.reset({
                            top: 0
                            });
                        });
                    }
                }
            });
        },
        onScrollBottom() {
            this.count++;
            if (this.count == 1) {
                this.getData();
            }
        },
        resetGet(){
            this.todolist = [];
            this.count=0;
            this.pageindex=1;
            this.getData();
        },
    }
}
</script>